package tjs.org.springLoader.fileWatch;

import java.util.LinkedList;

/**
 * Created by Nicky.Tang on 2021/9/29 11:58 下午
 *
 * @since 02.12.10
 */
public class OftenChangeQueue {
    private LinkedList<String> oftenChanges = new LinkedList<String>();
    private int maxNum;

    public OftenChangeQueue(int maxNum) {
        this.maxNum = maxNum;
    }

    public synchronized void leftPop(String fileName) {
        if (oftenChanges.size() >= 10) {
            this.rightPush();
        }
        oftenChanges.add(fileName);
    }

    private synchronized void rightPush() {
        oftenChanges.removeLast();
    }

    public LinkedList<String> getOftenChanges(){
        return this.oftenChanges;
    }
}
